package cn.lili.controller.feign;

import cn.lili.modules.operationcenter.client.OperationCenterClient;
import cn.lili.modules.operationcenter.entity.dos.OperationCenter;
import cn.lili.modules.operationcenter.entity.dos.OperationCenterWithdrawal;
import cn.lili.modules.operationcenter.entity.vos.OperationCenterSearchPageParams;
import cn.lili.modules.operationcenter.entity.vos.OperationCenterVo;
import cn.lili.modules.service.OperationCenterService;
import cn.lili.modules.service.OperationCenterWithdrawalService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class OperationCenterFeignController implements OperationCenterClient {

    private final OperationCenterService operationCenterService;

    private final OperationCenterWithdrawalService operationCenterWithdrawalService;

    @Override
    public OperationCenter getOperationCenter(String userId) {
        return operationCenterService.getOperationCenter(userId);
    }

    @Override
    public void addOperationCenter(OperationCenter operationCenter) {
        operationCenterService.add(operationCenter);
    }

    @Override
    public Page<OperationCenterVo> page(OperationCenterSearchPageParams operationCenterSearchPageParams) {
        return operationCenterService.findByConditionPage(operationCenterSearchPageParams.getOperationCenterSearchParams(), operationCenterSearchPageParams.getPage());
    }

    @Override
    public OperationCenter getByAddressId(String provinceId) {
        return operationCenterService.getByAddressId(provinceId);
    }

    @Override
    public OperationCenter getById(String id) {
        return operationCenterService.getById(id);
    }

    @Override
    public List<OperationCenter> select() {
        return operationCenterService.select(null);
    }

    @Override
    public List<OperationCenter> getOperationCenterListByProviceIds(List<String> provinceIdList) {
        return operationCenterService.getOperationCenterListByProviceIds(provinceIdList);
    }

    @Override
    public List<OperationCenter> getList() {
        LambdaQueryWrapper<OperationCenter> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(OperationCenter::getDeleteFlag, false);
        return operationCenterService.list(queryWrapper);
    }

    @Override
    public void insertWithdrawal(OperationCenterWithdrawal operationCenterWithdrawal) {
        operationCenterWithdrawalService.save(operationCenterWithdrawal);
    }
}
